home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / smsrc / sm / window_dt.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-11  |  2KB  |  104 lines

  1. Function OpenDTWin(fn : STRPTR) : pWindow;
  2.  
  3. VAR
  4.     nomwidth, nomheight,Junk : LONG;
  5.     win : pWindow;
  6.     t : Array[0..16] of LONG;
  7.  
  8. Begin
  9.     nomheight := 0;
  10.     nomwidth  := 0;
  11.     win := NIL;
  12.     if DataTypesBase = NIL then begin
  13.         dto := NIL;
  14.         CD.cd_ScrT := ST_NONE;
  15.         OpenDTWin := Win;
  16.         Exit;
  17.     end;
  18.     
  19.     { get datatype }
  20.     dto := NewDTObjectA(fn, NIL);
  21.     if dto <> NIL then begin
  22.         { get info }
  23.         t[0] := DTA_NominalHoriz;
  24.         t[1] := LONG(@nomwidth);
  25.         t[2] := DTA_NominalVert;
  26.         t[3] := LONG(@nomheight);
  27.         {If CD.cd_HAM then begin
  28.             cregs := AllocVec(CD.cd_ScrDepth*
  29.             t[4] := PDTA_ColorRegisters;}
  30.         t[4] := TAG_END;
  31.         if GetDTAttrsA(dto, @t) <> 0 then begin
  32.         
  33.             if nomwidth = 0 then 
  34.                 nomwidth := TheScreen^.Width;
  35.             if nomheight = 0 then 
  36.                 nomheight := TheScreen^.Height;
  37.                 
  38.             { open the window }
  39.             t[0]  := WA_InnerWidth;
  40.             t[1]  := nomwidth;
  41.             t[2]  := WA_InnerHeight;
  42.             t[3]  := nomheight;
  43.             t[4]  := WA_IDCMP;
  44.             t[5]  := IDCMP_IDCMPUPDATE|IDCMP_REFRESHWINDOW;
  45.             t[6]  := WA_BackDrop;
  46.             t[7]  := True_;
  47.             t[8]  := WA_SimpleRefresh;
  48.             t[9]  := True_;
  49.             t[10] := WA_BorderLess;
  50.             t[11] := True_;
  51.             t[12] := WA_Top;
  52.             t[13] := Sizes[TBS];
  53.             t[14] := WA_PubScreen;
  54.             t[15] := LONG(TheScreen);
  55.             t[16] := TAG_END;
  56.             win := OpenWindowTagList(NIL, @t);
  57.             if win <> NIL then begin
  58.                 { set dt dim. }
  59.                 t[ 0] := GA_Left;
  60.                 t[ 1] := win^.BorderLeft;
  61.                 t[ 2] := GA_Top;
  62.                 t[ 3] := win^.BorderTop;
  63.                 t[ 4] := GA_Width;
  64.                 t[ 5] := win^.Width - win^.BorderLeft - win^.BorderRight;
  65.                 t[ 6] := GA_Height;
  66.                 t[ 7] := win^.Height - win^.BorderTop - win^.BorderBottom;
  67.                 t[ 8] := ICA_TARGET;
  68.                 t[ 9] := ICTARGET_IDCMP;
  69.                 t[10] := DTA_Immediate;
  70.                 t[11] := LONG(CD.cd_DTImmed);
  71.                 t[12] := DTA_Repeat;
  72.                 t[13] := LONG(CD.cd_DTRepeat);
  73.                 t[14] := TAG_END;
  74.                 junk := SetDTAttrsA(dto, NIL, NIL, @t);
  75.                 
  76.                 { add object to the window }
  77.                 junk := AddDTObject(win, NIL, dto, -1);
  78.                 
  79.                 { refresh }
  80.                 RefreshDTObjectA(dto, win, NIL, NIL);
  81.             end;
  82.         end; { else begin
  83.             junk := IOErr;
  84.             Writeln('Can not load, error : ',junk);
  85.         end;}
  86.     end;
  87.     OpenDTWin := Win;
  88. end;
  89.  
  90. Procedure CloseDTWin(VAR win : pWindow);
  91. VAR
  92.     rc : LONG;
  93. begin
  94.     if DataTypesBase <> NIL then begin
  95.  
  96.         if dto <> NIL then begin
  97.             rc := RemoveDTObject(win, dto);
  98.             DisposeDTObject(dto);
  99.         end;
  100.         if win <> NIL then
  101.             CloseWindow(win);
  102.     end;
  103. end;
  104.